SKILLS_PER_UNIT = 4

class Unit(object):

    def load_state(self, state):
        pass

    def initial_state(self, name, unit_class, level):
        self.name = name
        self.unit_class = unit_class
        self.level = level
        self.attributes = UnitAttributes()
        self.attribute_modifiers = {}
        self.calc_attributes()
        self.calc_skills()

    def set_skills(self, skills):
        assert len(skills) == SKILLS_PER_UNIT
        self.skills = skills

    def set_attribute_modifiers(self, attribute_modifiers):
        self.attribute_modifiers = attribute_modifiers
        self.calc_attributes()

    def calc_attributes(self):
        """
        Recalculate the total attributes, given class, level and
        attribute_modifiers.
        """
        self.attributes.calc(self.unit_class, self.level,
                             self.attribute_modifiers)

    def calc_skills(self):
        """
        Generate a skill set compatible with the class and level of the unit.
        """
        self.skills = [None] * SKILLS_PER_UNIT


class UnitAttributes(dict):

    def __init__(self):
        self['str'] = 0
        self['con'] = 0
        self['dex'] = 0
        self['min'] = 0
        self['spi'] = 0

    def calc(self, unit_class, level, modifiers):
        pass
